package basic.base.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.bind.annotation.ModelAttribute;

public class BaseController {
	 protected ThreadLocal<HttpServletRequest> request = new ThreadLocal<HttpServletRequest>();
	    protected ThreadLocal<HttpServletResponse> response = new ThreadLocal<HttpServletResponse>();
	    protected ThreadLocal<HttpSession> session = new ThreadLocal<HttpSession>();


	    @ModelAttribute
	    public void setReqAndRes(HttpServletRequest request, HttpServletResponse response) {
	        this.request.set(request);
	        this.response.set(response);
	        this.session.set(request.getSession());
	    }

	    public HttpServletRequest getRequest() {
	        return request.get();
	    }

	    public HttpServletResponse getResponse() {
	        return response.get();
	    }

	    public HttpSession getSession() {
	        return session.get();
	    }
}